import 'dart:convert';
import 'package:meta/meta.dart';

class GoodDetail {
  final int product_id;
  final String product_name;
  final String product_icon;
  final String product_sbu;
  final int product_price;
  final int product_type;
  final String type_name;
  final int sale_count;
  final String product_detail;
  final String product_img;
  final String mall_url;
  GoodDetail(
      {
        @required this.product_id,
        @required this.product_name,
        @required this.product_icon,
        @required this.product_sbu,
        @required this.product_price,
        @required this.product_type,
        @required this.type_name,
        @required this.sale_count,
        @required this.product_detail,
        @required this.product_img,
        @required this.mall_url,
      });

  static GoodDetail fromJson(String json){
    GoodDetail _good;
    JsonDecoder decoder = new JsonDecoder();
    var mapData = decoder.convert(json)['data'];
    _good = new GoodDetail(
      product_id: mapData['product_id'],
      product_name: mapData['product_name'],
      product_icon: mapData['product_icon'],
      product_sbu: mapData['product_sub'],
      product_price: mapData['product_price'],
      product_type: mapData['product_type'],
      type_name: mapData['product_type_name'],
      sale_count: mapData['product_sale_count'],
      product_detail: mapData['product_detail'],
      product_img: mapData['product_img'],
      mall_url: mapData['product_mall_url'],
    );
    return _good;
  }
}